package com.yazif.vqa.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;


@Component
@PropertySource("classpath:application.properties")
public class Redis {
    @Value("${spring.redis.uri}")
    private String redisUri;

    @Autowired
    JedisPool jedisPool;

    @Bean
    public JedisPool getJedisPool(){
        JedisPool pool = new JedisPool(redisUri);
        return pool;
    }

    public Jedis getJedis(){
        return jedisPool.getResource();
    }
}
